/*
Filename: UDGetmassage.java
Precondition: System call.
Post-condition: get massage.
Main success Scenario:
1. System updates the main UI.
2a. Extensions: database connection err.
1. Massage box empty.

 */

package ucm;

/**
 *
 * @author Mark
 */

import model.DatabaseModel;

import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
public class UCGetmassage {
String massage;

    public UCGetmassage() {
                getMassage(massage);
    }

    public String getMassage(String massage){
        DatabaseModel dbModel = DatabaseModel.getInstance();
        Connection con = dbModel.getConnection();
        try {
            Statement stmt = con.createStatement(ResultSet.CONCUR_UPDATABLE,
                    ResultSet.CONCUR_UPDATABLE);
                         stmt.executeUpdate("INSERT INTO massages (`MASSAGE`) VALUES ('new massage')");
            ResultSet res = stmt.executeQuery("select * from massages where masid > 0");
             System.out.println(res.next());
             massage = res.getString("MASSAGE");
         
        } catch (Exception e) {
            e.printStackTrace();
        }
     return massage;
    }

}

